package ext.tianma.masschange.processor;

import java.io.IOException;
import java.rmi.RemoteException;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import java.util.Vector;

import wt.change2.WTChangeActivity2;
import wt.fc.PersistenceServerHelper;
import wt.part.LineNumber;
import wt.part.Quantity;
import wt.part.QuantityUnit;
import wt.part.WTPart;
import wt.part.WTPartMaster;
import wt.part.WTPartUsageLink;
import wt.session.SessionHelper;
import wt.session.SessionServerHelper;
import wt.util.WTException;
import wt.util.WTProperties;
import wt.util.WTPropertyVetoException;

import com.ptc.core.components.forms.DefaultObjectFormProcessor;
import com.ptc.core.components.forms.FormProcessingStatus;
import com.ptc.core.components.forms.FormResult;
import com.ptc.netmarkets.util.beans.NmCommandBean;

import ext.com.core.CoreUtil;
import ext.com.iba.IBAUtil;
import ext.tianma.masschange.log.BomMassChangeLog;
import ext.tianma.masschange.util.MassChangeProcessorUtil;
import ext.tianma.masschange.util.MassChangeUtil;

public class BomMassChangeFormProcessor extends DefaultObjectFormProcessor {
	private static String YIELD = "Yield";
	private static String RESOURCE = "ext.tianma.masschange.resource.MassChangeResource";
	private static String CLASSNAME="";
	private static boolean VERBOSE = true;
	private static WTProperties wtProperties;
	private static Locale locale = null;
	private static String MASSCHANGE_RESULT_TABLEID = "ext.tianma.masschange.builder.BomMassChangeSearchResultTableBuilder";

	static {

		try {
			CLASSNAME= BomMassChangeFormProcessor.class.getName();
			wtProperties = WTProperties.getLocalProperties();
			locale = SessionHelper.manager.getLocale();
			//VERBOSE = wtProperties.getProperty("ext.tianma.masschange.processor.verbose", false);
		}
		catch (IOException ioe) {
			ioe.printStackTrace();
		}catch (Throwable throwable) {
			throw new ExceptionInInitializerError(throwable);
		}
	}
	
	public BomMassChangeFormProcessor() {

	}
	
	 /**
	 *输出log信息
	 * @throws WTException 
	 */
	private static void outLogInfo(String obj) throws WTException {
		BomMassChangeLog.writeLog(obj);
	}
	
	private static void outLogWarn(String obj) throws WTException {
		BomMassChangeLog.writeWarnLog(obj);
	}
	
	/**
	 *输出log信息
	 * @throws WTException 
	 */
	private static void outLogInfo(String action, String obj) throws WTException {
		BomMassChangeLog.writeLog(action, obj);
	}
	
	 /**
	 *输出调试信息
	 */
	private static void outDebugInfo(String info) {
		if(VERBOSE)
			System.out.println(CLASSNAME+"......"+info);
	}
	
	public FormResult doOperation(NmCommandBean nmcommandbean, List list) throws WTException { 
		
		outDebugInfo("Start MassChangeFormProcessor");
	    FormResult formresult = new FormResult();
	    formresult.setStatus(FormProcessingStatus.SUCCESS);
	    boolean flag = SessionServerHelper.manager.isAccessEnforced();
	    
	    //获取MassChange类型
	    ArrayList BOM_MASSCHANGE_TYPE_ARRAY = (ArrayList)nmcommandbean.getComboBox().get("BOM_MASSCHANGE_TYPE");
	    String BOM_MASSCHANGE_TYPE = (String) BOM_MASSCHANGE_TYPE_ARRAY.get(0);
	    
	    //获取表单数据
	    //修改零件
	    String MODIFIED_PART_NUMBER_VALUE = (String) (nmcommandbean.getText().get("MODIFIED_PART$label$"));
	    String MODIFIED_PART_NAME_VALUE = (String) (nmcommandbean.getText().get("MODIFIED_PART_NAME"));
	    String MODIFIED_PART_VIEW_VALUE = (String) (nmcommandbean.getText().get("MODIFIED_PART_VIEW"));
	    
	    //参照零件
	    String REFERENCE_PART_NUMBER_VALUE = (String) (nmcommandbean.getText().get("REFERENCE_PART$label$"));
	    String REFERENCE_PART_NAME_VALUE = (String) (nmcommandbean.getText().get("REFERENCE_PART_NAME"));
	    String REFERENCE_PART_VIEW_VALUE = (String) (nmcommandbean.getText().get("REFERENCE_PART_VIEW"));
	    
	    String QUANTITY_VALUE = (String) (nmcommandbean.getText().get("QUANTITY"));
	    
	    //替换零件
	    String SUBSTITUTED_PART_NUMBER_VALUE = (String) (nmcommandbean.getText().get("SUBSTITUTED_PART$label$"));
	    String SUBSTITUTED_PART_NAME_VALUE = (String) (nmcommandbean.getText().get("SUBSTITUTED_PART_NAME"));
	    String SUBSTITUTED_PART_VIEW_VALUE = (String) (nmcommandbean.getText().get("SUBSTITUTED_PART_VIEW"));
	    
	    
	    outLogInfo(MassChangeProcessorUtil.getMessage("BOM_MASSCHANGE_START"));
	    //输出表单到log
	    outLogInfo(MassChangeProcessorUtil.getMessage("PRINT_FORM_DATA_START"));
	    outLogInfo(MassChangeProcessorUtil.getMessage("MODIFIED_PART"), MODIFIED_PART_NUMBER_VALUE);
	    outLogInfo(MassChangeProcessorUtil.getMessage("MODIFIED_PART_NAME"), MODIFIED_PART_NAME_VALUE);
	    outLogInfo(MassChangeProcessorUtil.getMessage("MODIFIED_PART_VIEW"), MODIFIED_PART_VIEW_VALUE);
	    outLogInfo(MassChangeProcessorUtil.getMessage("REFERENCE_PART"), REFERENCE_PART_NUMBER_VALUE);
	    outLogInfo(MassChangeProcessorUtil.getMessage("REFERENCE_PART_NAME"), REFERENCE_PART_NAME_VALUE);
	    outLogInfo(MassChangeProcessorUtil.getMessage("REFERENCE_PART_VIEW"), REFERENCE_PART_VIEW_VALUE);
	    outLogInfo(MassChangeProcessorUtil.getMessage("QUANTITY"), QUANTITY_VALUE);
	    outLogInfo(MassChangeProcessorUtil.getMessage("SUBSTITUTED_PART"), SUBSTITUTED_PART_NUMBER_VALUE);
	    outLogInfo(MassChangeProcessorUtil.getMessage("SUBSTITUTED_PART_NAME"), SUBSTITUTED_PART_NAME_VALUE);
	    outLogInfo(MassChangeProcessorUtil.getMessage("SUBSTITUTED_PART_VIEW"), SUBSTITUTED_PART_VIEW_VALUE);
	    outLogInfo(MassChangeProcessorUtil.getMessage("PRINT_FORM_DATA_END"));
	    //获取table中勾选的数据
	    Vector lines = MassChangeProcessorUtil.getSelectedData(nmcommandbean, MASSCHANGE_RESULT_TABLEID);
	    //获取CA
	    WTChangeActivity2 ca = MassChangeProcessorUtil.getCA(nmcommandbean);		   
	    outDebugInfo("ca = "+ca);
	    
	    if(ca!=null) {
		    if(lines.size()!=0) {
		    	outDebugInfo("lines.size()="+lines.size());
			    if(BOM_MASSCHANGE_TYPE.equalsIgnoreCase("MASSCHANGE_ADD_PART")) {
			    	outDebugInfo("MASSCHANGE_ADD_PART");		    	
			    	
			    	if(MODIFIED_PART_NUMBER_VALUE!=null && MODIFIED_PART_NUMBER_VALUE!="" && MODIFIED_PART_VIEW_VALUE!=null && MODIFIED_PART_VIEW_VALUE!="") {			    		
			    		outDebugInfo("Start MASSCHANGE_ADD_PART");	
			    					    		
			    		WTPart modifiedPart = CoreUtil.getWTPartByNumberAndView(MODIFIED_PART_NUMBER_VALUE, MODIFIED_PART_VIEW_VALUE);
			    		WTPartMaster modifiedPartMaster = (WTPartMaster) modifiedPart.getMaster();
			    		Vector changeAfter = new Vector();
			    		for(int i=0; i<lines.size(); i++) {
			    			Vector line = (Vector)lines.get(i);
			    			String number = (String) line.get(0);
			    			String view = (String)line.get(1);
			    			String quantityStr = (String)line.get(2);
			    			String unit = (String)line.get(3);
			    			String yield = (String)line.get(4);
			    			String lineNumberStr=(String)line.get(5);
			    			WTPart parent = CoreUtil.getWTPartByNumberAndView(number, view);
			    			Vector linkvc = MassChangeUtil.getPartUsageLink(parent, modifiedPart);
			    			if(linkvc!=null&&linkvc.size()>0) {
			    				//输出数据处理log
			    				StringBuffer stringbuffer = new StringBuffer();
				    			stringbuffer.append("父件[编码:"+number+", 名称:"+parent.getName()+", 视图:"+view +"]");
				    			stringbuffer.append(" - ");
				    			stringbuffer.append("修改零件[编码:"+MODIFIED_PART_NUMBER_VALUE +", 名称:"+MODIFIED_PART_NAME_VALUE+", 视图:"+MODIFIED_PART_VIEW_VALUE +"]");
				    			stringbuffer.append("之间已经存在使用关系！");
			    				outLogWarn(stringbuffer.toString());
			 				    continue;
			    			}
			    			
			    			LineNumber lineNumber=LineNumber.newLineNumber(Long.parseLong(lineNumberStr));
			    			double quantitDouble = Double.parseDouble(quantityStr);
			    			outDebugInfo("quantitDouble = " + quantitDouble);
			    			Quantity quantity=Quantity.newQuantity(quantitDouble, QuantityUnit.toQuantityUnit(unit));
			    			WTPart checkoutParent = MassChangeProcessorUtil.getCheckoutParent(number, view,ca);
			    			WTPartUsageLink link =WTPartUsageLink.newWTPartUsageLink(checkoutParent, modifiedPartMaster);
			    			link.setQuantity(quantity);
			    			outDebugInfo("lineNumber = " + lineNumber);
			    			try {
								link.setLineNumber(lineNumber);
							} catch (WTPropertyVetoException e1) {
								e1.printStackTrace();
							}
			    			PersistenceServerHelper.manager.insert(link);	
			    			IBAUtil.forceSetIBAValue(link, YIELD, yield);
			    			try {
								outDebugInfo("yield = " + IBAUtil.getIBAValue(link, YIELD));
							} catch (RemoteException e) {
								// TODO Auto-generated catch block
								e.printStackTrace();
							}
			    			CoreUtil.checkinObject(checkoutParent, "MASSCHANGE_ADD_PART");
			    			changeAfter.add(checkoutParent);
			    			
			    			//输出数据处理log
			    			StringBuffer stringbuffer = new StringBuffer();
			    			stringbuffer.append("创建");
			    			stringbuffer.append("父件[编码:"+number+", 名称:"+parent.getName()+", 视图:"+view +"]");
			    			stringbuffer.append(" - ");
			    			stringbuffer.append("修改零件[编码:"+MODIFIED_PART_NUMBER_VALUE +", 名称:"+MODIFIED_PART_NAME_VALUE+", 视图:"+MODIFIED_PART_VIEW_VALUE +"]");
			    			stringbuffer.append("之间的使用关系");
			    			stringbuffer.append("[数量:"+quantityStr+", 单位:"+ QuantityUnit.toQuantityUnit(unit).getDisplay(locale)+",行号:"+lineNumberStr+", 良率:"+yield+"]");
			    			outLogInfo(stringbuffer.toString());	    						    			
			    		}
			    		//store changeAfter
						try {
							MassChangeUtil.addChangeObjs(ca,changeAfter,"wt.change2.ChangeRecord2");
						} catch (Exception e) {
							e.printStackTrace();
						}
			    	}
			    } else if(BOM_MASSCHANGE_TYPE.equalsIgnoreCase("MASSCHANGE_DELETE_PART")){
			    	outDebugInfo("MASSCHANGE_DELETE_PART");
			    	if(MODIFIED_PART_NUMBER_VALUE!=null && MODIFIED_PART_NUMBER_VALUE!="" && MODIFIED_PART_VIEW_VALUE!=null && MODIFIED_PART_VIEW_VALUE!="") {
			    		outDebugInfo("Start MASSCHANGE_DELETE_PART");
			    		WTPart modifyPart = CoreUtil.getWTPartByNumberAndView(MODIFIED_PART_NUMBER_VALUE, MODIFIED_PART_VIEW_VALUE);
			    		WTPartMaster modifyPartMaster = (WTPartMaster) modifyPart.getMaster();
			    		Vector changeAfter = new Vector();
			    		for(int i=0; i<lines.size(); i++) {
			    			Vector line = (Vector)lines.get(i);
			    			String number = (String) line.get(0);
			    			String view = (String)line.get(1);
			    			WTPart parent = CoreUtil.getWTPartByNumberAndView(number, view);
			    			Vector linkvc = MassChangeUtil.getPartUsageLink(parent, modifyPart);			    					    					
			    			//移除link
			    			if(linkvc==null || linkvc.size()<=0) {
			    				//输出数据处理log
			    				StringBuffer stringbuffer = new StringBuffer();
				    			stringbuffer.append("父件[编码:"+number+", 名称:"+parent.getName()+", 视图:"+view +"]");
				    			stringbuffer.append(" - ");
				    			stringbuffer.append("修改零件[编码:"+MODIFIED_PART_NUMBER_VALUE +", 名称:"+MODIFIED_PART_NAME_VALUE+", 视图:"+MODIFIED_PART_VIEW_VALUE +"]");
				    			stringbuffer.append("之间不存在使用关系！");
			    				outLogWarn(stringbuffer.toString());
			    				continue;
			    			}
			    			WTPart checkoutParent = MassChangeProcessorUtil.getCheckoutParent(number, view,ca);
			    			Vector linkvc1 = MassChangeUtil.getPartUsageLink(checkoutParent, modifyPart);
			    			
			    			PersistenceServerHelper.manager.remove((WTPartUsageLink)linkvc1.get(0));
			    			
			    			CoreUtil.checkinObject(checkoutParent, "MASSCHANGE_DELETE_PART");
			    			changeAfter.add(checkoutParent);
			    			
			    			//输出数据处理log
			    			StringBuffer stringbuffer = new StringBuffer();
			    			stringbuffer.append("删除");
			    			stringbuffer.append("父件[编码:"+number+", 名称:"+parent.getName()+", 视图:"+view +"]");
			    			stringbuffer.append(" - ");
			    			stringbuffer.append("修改零件[编码:"+MODIFIED_PART_NUMBER_VALUE +", 名称:"+MODIFIED_PART_NAME_VALUE+", 视图:"+MODIFIED_PART_VIEW_VALUE +"]");
			    			stringbuffer.append("之间的使用关系");
			    			outLogInfo(stringbuffer.toString());
			    		}
			    		//store changeAfter						
						try {
							MassChangeUtil.addChangeObjs(ca,changeAfter,"wt.change2.ChangeRecord2");
						} catch (Exception e) {
							e.printStackTrace();
						}
						
			    	}			    	
			    } else if(BOM_MASSCHANGE_TYPE.equalsIgnoreCase("MASSCHANGE_SUBSTITUTE_PART")) {
			    	outDebugInfo("MASSCHANGE_SUBSTITUTE_PART");
			    	if(SUBSTITUTED_PART_NUMBER_VALUE!=null && SUBSTITUTED_PART_NUMBER_VALUE!="" && SUBSTITUTED_PART_VIEW_VALUE!=null && SUBSTITUTED_PART_VIEW_VALUE!=""
			    		&& MODIFIED_PART_NUMBER_VALUE!=null && MODIFIED_PART_NUMBER_VALUE!="" && MODIFIED_PART_VIEW_VALUE!=null && MODIFIED_PART_VIEW_VALUE!="") {
			    		outDebugInfo("Start MASSCHANGE_SUBSTITUTE_PART");			    		
			    		WTPart modifyPart = CoreUtil.getWTPartByNumberAndView(MODIFIED_PART_NUMBER_VALUE, MODIFIED_PART_VIEW_VALUE);
			    		WTPart substitutedPart = CoreUtil.getWTPartByNumberAndView(SUBSTITUTED_PART_NUMBER_VALUE, SUBSTITUTED_PART_VIEW_VALUE);
			    		WTPartMaster modifyPartPartMaster = (WTPartMaster)modifyPart.getMaster();
			    		Vector changeAfter = new Vector();
			    		for(int i=0; i<lines.size(); i++) {
			    			Vector line = (Vector)lines.get(i);
			    			String number = (String) line.get(0);
			    			String view = (String)line.get(1);
			    			String quantityStr = (String)line.get(2);
			    			String unit = (String)line.get(3);
			    			String yield = (String)line.get(4);
			    			String lineNumberStr=(String)line.get(5);
			    			WTPart parent = CoreUtil.getWTPartByNumberAndView(number, view);
			    			Vector linkvc = MassChangeUtil.getPartUsageLink(parent, substitutedPart);
			    			if(linkvc==null || linkvc.size()<=0) {
			    				//输出数据处理log
			    				StringBuffer stringbuffer = new StringBuffer();
				    			stringbuffer.append("父件[编码:"+number+", 名称:"+parent.getName()+", 视图:"+view +"]");
				    			stringbuffer.append(" - ");
				    			stringbuffer.append("被替换零件[编码:"+SUBSTITUTED_PART_NUMBER_VALUE +", 名称:"+SUBSTITUTED_PART_NUMBER_VALUE+", 视图:"+SUBSTITUTED_PART_VIEW_VALUE +"]");
				    			stringbuffer.append("之间不存在使用关系！");
			    				outLogWarn(stringbuffer.toString());
			    				continue;
			    			}	
			    			
			    			LineNumber lineNumber=LineNumber.newLineNumber(Long.parseLong(lineNumberStr));
			    			WTPart checkoutParent = MassChangeProcessorUtil.getCheckoutParent(number, view,ca);
			    			Vector linkvc1 = MassChangeUtil.getPartUsageLink(checkoutParent, substitutedPart);
			    			PersistenceServerHelper.manager.remove((WTPartUsageLink)linkvc1.get(0));
			    			double quantitDouble = Double.parseDouble(quantityStr);
			    			Quantity quantity=Quantity.newQuantity(quantitDouble, QuantityUnit.toQuantityUnit(unit));
			    			WTPartUsageLink link = WTPartUsageLink.newWTPartUsageLink(checkoutParent, modifyPartPartMaster);			
			    			link.setQuantity(quantity);	
			    			try {
								link.setLineNumber(lineNumber);
							} catch (WTPropertyVetoException e) {
								e.printStackTrace();
							}
			    			PersistenceServerHelper.manager.insert(link);
			    			IBAUtil.forceSetIBAValue(link, YIELD, yield);
			    			CoreUtil.checkinObject(checkoutParent, "MASSCHANGE_SUBSTITUTE_PART");
			    			changeAfter.add(checkoutParent);
			    			//输出数据处理log
			    			StringBuffer stringbuffer = new StringBuffer();
			    			stringbuffer.append("删除");
			    			stringbuffer.append("父件[编码:"+number+", 名称:"+parent.getName()+", 视图:"+view +"]");
			    			stringbuffer.append(" - ");
			    			stringbuffer.append("被替换零件[编码:"+SUBSTITUTED_PART_NUMBER_VALUE +", 名称:"+SUBSTITUTED_PART_NAME_VALUE+", 视图:"+SUBSTITUTED_PART_VIEW_VALUE +"]");
			    			stringbuffer.append("之间的使用关系. ");
			    			stringbuffer.append("并创建");
			    			stringbuffer.append("父件[编码:"+number+", 名称:"+parent.getName()+", 视图:"+view +"]");
			    			stringbuffer.append(" - ");
			    			stringbuffer.append("修改零件[编码:"+MODIFIED_PART_NUMBER_VALUE +", 名称:"+MODIFIED_PART_NAME_VALUE+", 视图:"+MODIFIED_PART_VIEW_VALUE +"]");
			    			stringbuffer.append("之间的使用关系");
			    			stringbuffer.append("[数量:"+quantityStr+", 单位:"+ QuantityUnit.toQuantityUnit(unit).getDisplay(locale)+",行号:"+lineNumberStr+", 良率:"+yield+"]");
			    			outLogInfo(stringbuffer.toString());
			    			
			    		}
			    		//store changeAfter
						try {
							MassChangeUtil.addChangeObjs(ca,changeAfter,"wt.change2.ChangeRecord2");
						} catch (Exception e) {
							e.printStackTrace();
						}
			    		
			    	}
			    } else if(BOM_MASSCHANGE_TYPE.equalsIgnoreCase("MASSCHANGE_QUANTITY_PART")) {
			    	outDebugInfo("MASSCHANGE_QUANTITY_PART");
			    	if(MODIFIED_PART_NUMBER_VALUE!=null && MODIFIED_PART_NUMBER_VALUE!="" && MODIFIED_PART_VIEW_VALUE!=null && MODIFIED_PART_VIEW_VALUE!="") {
			    		outDebugInfo("Start MASSCHANGE_QUANTITY_PART");
			    		WTPart modifyPart = CoreUtil.getWTPartByNumberAndView(MODIFIED_PART_NUMBER_VALUE, MODIFIED_PART_VIEW_VALUE);
			    		WTPartMaster modifyPartPartMaster = (WTPartMaster)modifyPart.getMaster();
			    		Vector changeAfter = new Vector();
			    		for(int i=0; i<lines.size(); i++) {
			    			Vector line = (Vector)lines.get(i);
			    			String number = (String) line.get(0);
			    			String view = (String)line.get(1);
			    			String quantityStr = (String)line.get(2);
			    			String unit = (String)line.get(3);
			    			String yield = (String)line.get(4);
			    			String lineNumberStr=(String)line.get(5);
			    			WTPart parent = CoreUtil.getWTPartByNumberAndView(number, view);
			    			Vector linkvc = MassChangeUtil.getPartUsageLink(parent, modifyPart);			    					    					
			    			//移除link
			    			if(linkvc==null || linkvc.size()<=0) {
			    				//输出数据处理log
			    				StringBuffer stringbuffer = new StringBuffer();
				    			stringbuffer.append("父件[编码:"+number+", 名称:"+parent.getName()+", 视图:"+view +"]");
				    			stringbuffer.append(" - ");
				    			stringbuffer.append("修改零件[编码:"+MODIFIED_PART_NUMBER_VALUE +", 名称:"+MODIFIED_PART_NAME_VALUE+", 视图:"+MODIFIED_PART_VIEW_VALUE +"]");
				    			stringbuffer.append("之间不存在使用关系！");
			    				outLogWarn(stringbuffer.toString());
			    				continue;
			    			}
			    			
			    			LineNumber lineNumber=LineNumber.newLineNumber(Long.parseLong(lineNumberStr));
			    			WTPart checkoutParent = MassChangeProcessorUtil.getCheckoutParent(number, view, ca);
			    			Vector linkvc1 = MassChangeUtil.getPartUsageLink(checkoutParent, modifyPart);
			    			WTPartUsageLink link =  (WTPartUsageLink)linkvc1.get(0);
			    			Quantity quantity = link.getQuantity();	
			    			try {
								link.setLineNumber(lineNumber);
							} catch (WTPropertyVetoException e) {
								// TODO Auto-generated catch block
								e.printStackTrace();
							}
			    			double quantitDouble = Double.parseDouble(quantityStr);
			    			//WTPartUsageLink link1 = WTPartUsageLink.newWTPartUsageLink(checkoutParent, modifyPartPartMaster);
			    			outDebugInfo("quantitDouble="+quantitDouble);
			    			quantity.setAmount(quantitDouble); 
			    			quantity.setUnit(QuantityUnit.toQuantityUnit(unit));
			    			PersistenceServerHelper.manager.update(link);
			    			IBAUtil.forceSetIBAValue(link, YIELD, yield);
			    			CoreUtil.checkinObject(checkoutParent, "MASSCHANGE_DELETE_PART");
			    			changeAfter.add(checkoutParent);
			    			
			    			//输出数据处理log
			    			StringBuffer stringbuffer = new StringBuffer();
			    			stringbuffer.append("修改");
			    			stringbuffer.append("父件[编码:"+number+", 名称:"+parent.getName()+", 视图:"+view +"]");
			    			stringbuffer.append(" - ");
			    			stringbuffer.append("修改零件[编码:"+MODIFIED_PART_NUMBER_VALUE +", 名称:"+MODIFIED_PART_NAME_VALUE+", 视图:"+MODIFIED_PART_VIEW_VALUE +"]");
			    			stringbuffer.append("之间的使用关系");
			    			stringbuffer.append("[数量:"+quantityStr+", 单位:"+ QuantityUnit.toQuantityUnit(unit).getDisplay(locale)+",行号:"+lineNumberStr+", 良率:"+yield+"]");
			    			outLogInfo(stringbuffer.toString());
			    		}
			    		//store changeAfter						
						try {
							MassChangeUtil.addChangeObjs(ca,changeAfter,"wt.change2.ChangeRecord2");
						} catch (Exception e) {
							e.printStackTrace();
						}
						
			    	}
			    }  
		    }
	    }
	    outLogInfo(MassChangeProcessorUtil.getMessage("BOM_MASSCHANGE_END"));
		super.doOperation(nmcommandbean, list);
		return formresult;
	}
	
	
	
}


